package com.usian.controller;

import com.usian.pojo.SearchItem;
import com.usian.service.SearchItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SearchItemServiceController {

    @Autowired
    SearchItemService searchItemService;

    /**
     * 商品搜索
     * @param q
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list")
    public List<SearchItem> searchItemList(@RequestParam String q, @RequestParam Integer pageNum, @RequestParam  Integer pageSize){
        return searchItemService.searchItemList(q,pageNum,pageSize);
    }

    /**
     * 商品库导入索引库  mysql导入ES
     * @return
     */
    @RequestMapping("importAll")
    public Boolean importAll(){
        return searchItemService.importAll();
    }
}
